﻿using JzSport.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JzSport.Api
{
    /// <summary>
    /// 修改性别
    /// </summary>
    class ChangeSexAction : AuthPostAction<Params.ChangeSexParams,
        Results.ChangeSexResult>
    {
        protected override ActionResult<Results.ChangeSexResult> OnExecute(ActionContext context, SysParameters sysParameters,
            Params.ChangeSexParams opParams)
        {
            ServiceResult<string> serviceResult = new AccountService().ChangeSex(context.AccountId,
                opParams.Sex);

            Results.ChangeSexResult actionResult = new Results.ChangeSexResult();

            if (serviceResult.ErrorCode == ErrorCode.NoError)
            {
                return new ActionResult<Results.ChangeSexResult>(true, serviceResult.ErrorCode,
                    ErrorCode.ToString(serviceResult.ErrorCode), actionResult);
            }
            return new ActionResult<Results.ChangeSexResult>(false, serviceResult.ErrorCode,
                    ErrorCode.ToString(serviceResult.ErrorCode), actionResult);
        }
    }
}
